package com.xiaoshuidi.cloud.module.report.controller.finance;


import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.report.controller.finance.vo.ExportRespVO;
import com.xiaoshuidi.cloud.module.report.controller.finance.vo.SumIncomePageReqVO;
import com.xiaoshuidi.cloud.module.report.controller.finance.vo.SumIncomePageRespVO;
import com.xiaoshuidi.cloud.module.report.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.report.service.finance.IncomeSummaryReportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

/**
 * 收入汇总报表
 */

@Slf4j
@Tag(name = "管理后台 - 收入汇总报表")
@RestController
@RequestMapping(ApiConstants.PREFIX+"/income")
public class IncomeSummaryReportController {

    @Resource
    private IncomeSummaryReportService incomeSummaryReportService;

    @PostMapping("/totalInPage")
    @Operation(summary = "收入汇总分页查询")
    public CommonResult<PageResult<SumIncomePageRespVO>> totalInPage(@RequestBody @Valid SumIncomePageReqVO reqVO) {
        log.info("IncomeSummaryReportController totalInPage req:{}",reqVO.toString());
        return success(incomeSummaryReportService.totalIncomePage(reqVO));
    }

    /**
     * 收入汇总表导出
     *
     * @param req
     * @return
     */
    @PostMapping("/totalInExport")
    public CommonResult<ExportRespVO> sumIncomeExport(@RequestBody @Valid SumIncomePageReqVO req) {
        log.info("IncomeSummaryReportController sumIncomeExport :{}",req.toString());
       return CommonResult.success(incomeSummaryReportService.sumIncomeExport(req));
    }

}
